local bolan = fk.CreateSkill{
  name = "gai__bolan",
  attached_skill_name = "gai__bolan&",
}

Fk:loadTranslationTable{
  ["gai__bolan"] = "博览",
  [":gai__bolan"] = "出牌阶段开始时，你可以从随机三个“出牌阶段限一次”的技能中选择一个获得直到本阶段结束；其他角色的出牌阶段限一次，"..
  "其可以失去1点体力，令你从随机三个“出牌阶段限一次”的技能中选择一个，其获得之直到此阶段结束。",

  ["#bolan-choice"] = "博览：选择令 %dest 此阶段获得技能",

  ["$gai__bolan1"] = "博览群书，融会贯通。",
  ["$gai__bolan2"] = "博览于文，约之以礼。",
}

BolanSkills = {
  "quhu", "qiangxi", "qice", "daoshu", "ol_ex__tiaoxin", "qiangwu", "tianyi", "ex__zhiheng", "ex__jieyin", "ex__guose",
  "lijian", "qingnang", "ty_ex__mingce", "mizhao", "sanchen", "os__gongxin", "ex__chuli", "ol_ex__mieji", "anguo",
  "boyan", "yingshui", "zundi", "ty__kuangfu", "choufa", "ol_ex__changbiao",
}

---@param room Room
local getBolanSkills = function(room)
  return BolanSkills
end

bolan:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(bolan.name) and player.phase == Player.Play
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local skills = table.filter(getBolanSkills(room), function (skill_name)
      return not player:hasSkill(skill_name, true)
    end)
    if #skills > 0 then
      local choice = room:askToChoice(player, {
        choices = table.random(skills, 3),
        skill_name = bolan.name,
        prompt = "#bolan-choice::"..player.id,
        detailed = true,
      })
      room:handleAddLoseSkills(player, choice)
      room.logic:getCurrentEvent():findParent(GameEvent.Phase):addCleaner(function()
        room:handleAddLoseSkills(player, "-"..choice)
      end)
    end
  end,
})

return bolan